import com.baomidou.mybatisplus.autoconfigure.MybatisPlusLanguageDriverAutoConfiguration;
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.config.TemplateConfig;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafTemplateAvailabilityProvider;

import java.util.Collections;
import java.util.function.Consumer;

public class Generator {
    public static void main(String[] args) {
        FastAutoGenerator.create("jdbc:mysql://db.com:3306/kaicheba?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai", "root", "Guo7764@9d")
//        FastAutoGenerator.create("jdbc:mysql://db.com:3306/kaicheba", "root", "Guo7764@9d")
                .globalConfig(builder -> {
                    builder.author("jinyu") // 设置作者
                            .enableSwagger() // 开启 swagger 模式
                            .fileOverride() // 覆盖已生成文件
                            .outputDir("/Users/jinyuhe/Downloads/baidu/source_code/mybatis-generator/src/main"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com.kaiche") // 设置父包名
                            .pathInfo(Collections.singletonMap(OutputFile.xml, "/Users/jinyuhe/Downloads/baidu/source_code/mybatis-generator/src/main")); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.addInclude("kcb_relation","kcb_report","kcb_room","kcb_user") // 设置需要生成的表名
                            .addTablePrefix("t_", "c_"); // 设置过滤表前缀
                })
                .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .execute();

    }
}
